//
//  MenuViewController.m
//  Rockval
//
//  Created by TuanNT on 4/28/14.
//  Copyright (c) 2014 TNL. All rights reserved.
//

#import "MenuViewController.h"
#import "SSToolkit.h"

@interface MenuViewController () {
}

@end

@implementation MenuViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
	self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
	if (self) {
		// Custom initialization
	}
	return self;
}

- (void)viewDidLoad {
	[super viewDidLoad];
	// Do any additional setup after loading the view.
	[self setUpView];
}

- (void)didReceiveMemoryWarning {
	[super didReceiveMemoryWarning];
	// Dispose of any resources that can be recreated.
}

/*
   #pragma mark - Navigation

   // In a storyboard-based application, you will often want to do a little preparation before navigation
   - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
   {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
   }
 */

//================================ METHODS ================================
#pragma mark -
#pragma mark METHODS

- (void)setUpView {
	[self setTitle:@"My Rockval"];

	SAMGradientView *gradientView = [[SAMGradientView alloc] initWithFrame:self.tableView.bounds];
	// Set the gradient colors
	gradientView.gradientColors = @[[UIColor colorWithRed:0.498 green:0.549 blue:0.675 alpha:1.000],
	                                [UIColor colorWithRed:0.235 green:0.282 blue:0.384 alpha:1.000]];

	// Optionally set some locations
	// gradientView.gradientLocations = @[@0.8, @1.0];

	// Optionally change the direction. The default is vertical.
	gradientView.gradientDirection = SAMGradientViewDirectionVertical;

	// Add it as a subview in all of its awesome
	[self.tableView setBackgroundView:gradientView];
}

//================================ UITABLEVIEW DATASOURCE ================================
#pragma mark -
#pragma mark UITABLEVIEW DATASOURCE

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	[tableView deselectRowAtIndexPath:indexPath animated:YES];

	UIViewController *vc = nil;
	switch (indexPath.row) {
		case 0: // For Sale
			vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ForSaleViewController"];
			break;

		case 1: // For Lease
			vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ForLeaseViewController"];
			break;

		case 2: // Filter
			vc = [self.storyboard instantiateViewControllerWithIdentifier:@"FilterViewController"];
			break;

		case 3:
			//vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ForSaleViewController"];
			break;

		case 4: // Recent Activities
			vc = [self.storyboard instantiateViewControllerWithIdentifier:@"RecentActivityViewController"];
			break;

		case 5: // My Listings
			vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ListingViewController"];
			break;

		case 6: // My Watching List
			vc = [self.storyboard instantiateViewControllerWithIdentifier:@"WatchingListViewController"];
			break;

		case 7:
			//vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ForSaleViewController"];
			break;

		case 8: // My Contacts
			vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyContactsTableViewController"];
			break;

		case 9: // My Profiles
			vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ProfilesViewController"];
			break;

		default:
			break;
	}
	if (vc) {
		BaseNavigationController *navigationController = self.menuContainerViewController.centerViewController;
		[self.menuContainerViewController setMenuState:MFSideMenuStateClosed];
		if ([vc isKindOfClass:[navigationController.topViewController class]]) {
			return;
		}
		navigationController.viewControllers = @[vc];
	}
}

@end
